package com.example.demo2.controller;

import com.example.demo2.bean.Travel;
import com.example.demo2.service.TravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*",
        methods = {RequestMethod.GET, RequestMethod.OPTIONS, RequestMethod.POST})
public class TravelController {
    @Autowired
    TravelService yourBeanService;


    // 查询所有
    @RequestMapping("/h8/travel/list")
    public Map<String, Object> list() {
        Map<String, Object> map = new HashMap<>();
        List<Travel> list = yourBeanService.list();
        if (list != null) {
            map.put("success", true);
            map.put("msg", "成功");
            map.put("list", list);
        } else {
            map.put("success", false);
            map.put("msg", "失败");
        }
        return map;
    }
}

